import config from "@/config"
import http from "@/utils/request"

export default {
    admin: {
        updatePassword: {
            url: `${config.API_URL}/admins/:id/password`,
            name: "修改密码",
            put: async function (id, data = {}) {
                return await http.put(this.url.replace(':id', id), data);
            }
        },
    },
    activity: {
        list: {
            url: `${config.API_URL}/activities`,
            name: "获取列表",
            get: async function (params = {}, config = {}) {
                return await http.get(this.url, params, config);
            }
        },
        save: {
            url: `${config.API_URL}/activities`,
            name: "保存",
            post: async function (data = {}) {
                return await http.post(this.url, data);
            }
        },
        registration: {
            list: {
                url: `${config.API_URL}/activity/registrations`,
                name: "获取列表",
                get: async function (params = {}, config = {}) {
                    return await http.get(this.url, params, config);
                }
            },
        },
        top: {
            url: `${config.API_URL}/activities/:id/top`,
            name: "置顶",
            post: async function (id, data = {}) {
                return await http.post(this.url.replace(':id', id), data);
            }
        },
        sort: {
            url: `${config.API_URL}/activities/:id/sort`,
            name: "排序",
            post: async function (id, sort) {
                return await http.post(this.url.replace(':id', id), { sort });
            }
        },
        comment: {
            list: {
                url: `${config.API_URL}/activity/comments`,
                name: "获取列表",
                get: async function (params = {}) {
                    return await http.get(this.url, params);
                }
            },
            check: {
                url: `${config.API_URL}/activity/comments/:id/check`,
                name: "审核",
                post: async function (id, data = {}) {
                    return await http.post(this.url.replace(':id', id), data);
                }
            },
            reply: {
                url: `${config.API_URL}/activity/comments/:id/reply`,
                name: "回复",
                post: async function (id, data = {}) {
                    return await http.post(this.url.replace(':id', id), data);
                }
            }
        }
    },
    coupon: {
        list: {
            url: `${config.API_URL}/coupons`,
            name: "获取列表",
            get: async function (params = {}) {
                return await http.get(this.url, params);
            }
        },
        save: {
            url: `${config.API_URL}/coupons`,
            name: "保存",
            post: async function (data = {}) {
                return await http.post(this.url, data);
            }
        },
        send: {
            url: `${config.API_URL}/coupons/:id/send`,
            name: "保存",
            post: async function (id, data = {}) {
                return await http.post(this.url.replace(':id', id), data);
            }
        },
        sendLog: {
            url: `${config.API_URL}/coupon/send-logs`,
            name: "获取列表",
            get: async function (params = {}) {
                return await http.get(this.url, params);
            }
        }
    },
    withdrawal: {
        list: {
            url: `${config.API_URL}/withdrawals`,
            name: "获取列表",
            get: async function (params = {}) {
                return await http.get(this.url, params);
            }
        },
        detail: {
            url: `${config.API_URL}/withdrawals/:id`,
            name: "详情",
            get: async function (id) {
                return await http.get(this.url.replace(':id', id));
            }
        },
        save: {
            url: `${config.API_URL}/withdrawals`,
            name: "保存",
            post: async function (data = {}) {
                return await http.post(this.url, data);
            }
        },
        approval: {
            url: `${config.API_URL}/withdrawals/:id/approval`,
            name: "审批",
            post: async function (id, data = {}) {
                return await http.post(this.url.replace(':id', id), data);
            }
        },
    },
    department: {
        detail: {
            url: `${config.API_URL}/departments/:id`,
            name: "详情",
            get: async function (id) {
                return await http.get(this.url.replace(':id', id));
            }
        }
    }
}